% This script generates Figures A.2.a and A.2.b in the online appendix.
% Figure A.2.a: Labor Conflict over Time / Work Stoppage Rate in Rust Belt
%% Generate simulated data:
clearvars;
rng(2022);
N = 1793;
T = 51;
vT = 1950:1:2000;
lambda = 0.47;
N_R = round(N*lambda);
N_S = N - N_R;
epsilon_bar = 0.418; % Calibrating to strike probability in rust belt
sigma = 2.48;
epsilon_tilde = epsilon_bar - 1/(sigma-1);
prob_strike = unifcdf(epsilon_tilde,-epsilon_bar,epsilon_bar);
mshock = rand(T,N).*2.*epsilon_bar-epsilon_bar;
mstrike = mshock < epsilon_tilde;
mstrike(:,N_R+1:end) = 0;
mstrike(30,floor(0.9*N_R)+1:N_R) = 0;
mstrike(31,floor(0.8*N_R)+1:N_R) = 0;
mstrike(32,floor(0.7*N_R)+1:N_R) = 0;
mstrike(33,floor(0.6*N_R)+1:N_R) = 0;
mstrike(34,floor(0.5*N_R)+1:N_R) = 0;
mstrike(35,floor(0.4*N_R)+1:N_R) = 0;
mstrike(36,floor(0.3*N_R)+1:N_R) = 0;
mstrike(37:end,floor(0.2*N_R)+1:N_R) = 0;
share_offering = ones(T,1);
share_offering(end-14:end) = 1/5;
share_offering(30:36) = interp1([1978 1986],[1 1/5],1979:1:1985);
vstrike_rate_rb = sum(mstrike,2)./N_R;
mprofits = exp(mshock.*(sigma-1)).*(1-mstrike);
request = exp(epsilon_tilde.*(sigma-1)-1);
mrents = mstrike.*request;
rent_share = sum(mrents,2)./lambda;
%% Generate Figure A.2.a
figure(102);
% Subplot A.2.a:
subplot(1,2,1)
plot(vT,vstrike_rate_rb,'linewidth',2)
xlabel('﻿Work Stoppage Rate in Rust Belt','Fontsize',12,'FontWeight','bold')
pbaspect([1.2 1 1]);
set(gca,'box','off','TickDir','out','Fontsize',11);
xlim([1950 2000])
% Subplot A.2.b:
subplot(1,2,2)
plot(vT,rent_share./rent_share(1),'linewidth',2)
xlabel('Wage Premium in Rust Belt, 1950 = 1','Fontsize',12,'FontWeight','bold')
pbaspect([1.2 1 1]);
xlim([1950 2000])
set(gca,'box','off','TickDir','out','Fontsize',11);
%% Save Figure A.2 in PDF and EPS file formats.
saveas(gcf,'figA-2.pdf');
saveas(gcf,'figA-2','epsc');